import java.util.Scanner;

/**
 * @Question 小平方
 * @Date 2023/3/8 9:09
 * @Solution
 */
public class 小平方 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double n=scanner.nextDouble();
        int count=0;
        double tar=n/2;
        for(int i=1;i<n;i++) {
            if(Math.pow(i,2)%n<tar) {
                count++;
            }
        }
        System.out.println(count);
    }
}
